<?php if (!defined('THINK_PATH')) exit(); echo W('Header');?>
<div class="block">
    <form action="<?php echo U(GROUP_NAME.'/Order/checkout');?>" method="post" name="theForm" id="theForm">
        <div class="flowBox">
            <h6><span>商品列表</span></h6>
            <table width="100%">
                <th class="select-all J_SelectAll" bgcolor="#ffffff" style="text-align:left; margin-left:5px;"></th>
                <th bgcolor="#ffffff" style="width:40%; text-align:center">商品名称</th>
                <th bgcolor="#ffffff" style="text-align: center;width:18%">单价(元)</th>
                <th bgcolor="#ffffff" style="text-align: center;width:18%">数量</th>
                <th bgcolor="#ffffff" style="text-align: center;width:18%">金额(元)</th>
            </table>
            <table width="100%" style="border:#ccc solid 1px;text-align:center">
                <?php if(is_array($data["goodsArr"])): foreach($data["goodsArr"] as $key=>$v): ?><tr id="tr_goods_<?php echo ($v["goods_id"]); ?>" class="cartList" style="border:#f00 solid 1px;">
                        <td style="width:5%">
                            <input name="goodsArr[<?php echo ($v["goods_id"]); ?>]" value="<?php echo ($v["num"]); ?>" type="hidden">
                        </td>
                        <td bgcolor="#ffffff" class="nstep_pbox" style="width:35%">
                            <p class="f_l"><a href="<?php echo U(GROUP_NAME.'/Goods/index',array('id'=>$v['goods_id']));?>"
                                              target="_blank"><img src="<?php echo U('/'.$v['goods']['img']);?>" border="0"
                                                                   title="<?php echo ($goods['name']); ?>" width="80" height="80"/></a>
                            </p>
                            <p class="nstep_name" style="text-align: left;width: 186px;height: 65px;overflow: hidden;margin: 30px 0 0 0px;text-overflow: ellipsis;font-size: 12px;float: left;">
                                <a href="<?php echo U(GROUP_NAME.'/Goods/index',array('id'=>$v['goods_id']));?>"
                                   target="_blank" class="f6"><?php echo ($v['goods']['name']); ?></a>
                            </p>
                        </td>
                        <td bgcolor="#ffffff" style="width:15%">
                            <p class="price-line">
                                <em class="price-original"
                                    style="text-align: center">￥<?php echo ($v['goods']['market_price']); ?>元</em>
                            </p>
                            <p class="price-line">
                                <em class="price-now" style="text-align: center">￥<?php echo ($v['goods']['shop_price']); ?>元</em>
                            </p>
                        </td>
                        <td bgcolor="#ffffff" style="width:15%;text-align: center">
                            <?php echo ($v["num"]); ?>
                        </td>
                        <td style="width:15%" bgcolor="#ffffff" id="goods_subtotal_<?php echo ($v["goods_id"]); ?>" class="chkprice ">
                            ￥<em name="price_<?php echo ($v["goods_id"]); ?>"><?php echo ($v['goods']['market_price']*$v["num"]); ?></em>元
                        </td>
                    </tr><?php endforeach; endif; ?>
            </table>
            <table width="100%">
                <tr>
                    <td bgcolor="#ffffff" id="total_desc" class="nstep1_count">
                        <div class="float-bar-wrapper">
                            <div  style="font-size: 20px; float: right;padding: 8px;">
                                购物金额总计 ￥<span id='sum'><?php echo ($data["sum"]); ?></span>元
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
            <!-- <input type="hidden" name="step" value="update_cart" />-->
        </div>
        <br>
        <div class="flowBox">
            <h6><span>配送方式</span></h6>
            <table style="text-align: center" id="shippingTable" cellpadding="5" cellspacing="1" width="99%">
                <tbody>
                <tr>
                    <th width="5%"></th>
                    <th width="25%">名称</th>
                    <th width="25%">描述</th>
                    <th width="15%">费用</th>
                </tr>
                <?php if(is_array($data["shipping"])): foreach($data["shipping"] as $key=>$v): ?><tr>
                        <td valign="top" style="text-align: left;padding-left: 20px">
                            <input class="shipping" name="shipping" id="<?php echo ($v["id"]); ?>" onclick="addFee(this)" value="<?php echo ($v["id"]); ?>" type="radio"/>
                        </td>
                        <td valign="top"><strong><?php echo ($v["name"]); ?></strong></td>
                        <td valign="top"><strong><?php echo ($v["describe"]); ?></strong></td>
                        <td align="center" valign="top" >￥<span id="shipping_<?php echo ($v["id"]); ?>"><?php echo ($v["fee"]); ?></span>元</td>
                    </tr><?php endforeach; endif; ?>
                </tbody>
            </table>
        </div>

        <div class="blank"></div>
        <br>
        <div class="flowBox">
            <h6><span>收货人信息</span></h6>
            <table cellpadding="5" cellspacing="1" width="99%" style="font-size: 16px;padding-left: 20px">
                <tbody style="text-align: right">
                <tr style="height: 50px;">
                    <td>收货人姓名:</td>
                    <td style="text-align: left"><input type="text" style="height: 30px" name="consignee_name"/></td>
                </tr>
                <tr style="height: 50px">
                    <td>联系电话:</td>
                    <td style="text-align: left"><input type="text" style="height: 30px" name="consignee_telephone"/></td>
                </tr>
                <tr id="address" style="height: 50px">
                    <td>详细地址:</td>
                    <td style="text-align: left"><textarea name="consignee_address" rows="3" cols="30"></textarea></td>
                </tr>
                <tr id="store" style="height: 50px">
                    <td>门店地址:</td>
                    <td style="text-align: left">
                        <br>
                        <input name="store" value="0" type="radio" style="display: none" checked/>
                        <?php if(is_array($data["store"])): foreach($data["store"] as $key=>$v): ?><input name="store" value="<?php echo ($v["id"]); ?>" type="radio"/><?php echo ($v["address"]); ?><br><?php endforeach; endif; ?>
                    </td>
                </tr>
                <tr  style="height: 50px">
                    <td>备注:</td>
                    <td style="text-align: left">
                        <textarea name="remark" rows="3" cols="30"></textarea>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="blank"></div>
        <div class="blank"></div>
        <br>
        <div class="flowBox">
            <h6><span>支付方式</span></h6>
            <table  id="paymentTable" cellpadding="5" cellspacing="1" width="99%">
                <tbody>
                <tr>
                    <th width="5%"></th>
                    <th width="25%">名称</th>
                    <th width="15%">手续费(商品总金额百分比)</th>
                </tr>
                <?php if(is_array($data["payment"])): foreach($data["payment"] as $key=>$v): ?><tr style="text-align: center">
                        <td style="text-align: left;padding-left: 20px" valign="top">
                            <input class="payment" name="payment" value="<?php echo ($v["id"]); ?>" onclick="addFee(this)" iscod="0" type="radio"/></td>
                        <td valign="top"><strong><?php echo ($v["name"]); ?></strong></td>
                        <td align="center" valign="top" ><span id="payment_<?php echo ($v["id"]); ?>"><?php echo ($v["fee"]); ?></span>%</td>
                    </tr><?php endforeach; endif; ?>
                </tbody>
            </table>
        </div>
        <div class="blank"></div>
        <div class="blank"></div>
        <br>
        <div class="flowBox">
            <h6><span>费用总计</span></h6>
            <div id="ECS_ORDERTOTAL">
                <table cellpadding="5" cellspacing="1" width="99%">
                    <tbody style="font-size: 20px">
                    <tr>
                        <input type="hidden" name="sum" value="<?php echo ($data["sum"]); ?>">
                        <td align="right"> 商品总价: <font class="f4_b">￥<?php echo ($data["sum"]); ?>元</font></td>
                    </tr>
                    <tr>
                        <input type="hidden" name="total" value="<?php echo ($data["sum"]); ?>">
                        <td align="right"> 应付款金额: <font class="f4_b">￥<span id="total"><?php echo ($data["sum"]); ?></span>元</font></td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div style="margin: 15px auto;text-align: center">
                <input type="submit" value='提交订单' style="height: 40px;width:150px;"/>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        function addFee(obj){
            var total=parseFloat($('#sum').html());
            var payment=$("input[name='payment']:checked").val();
            var shipping=$("input[name='shipping']:checked").val();
            var paymentFee=$('#payment_'+payment).html();
            var shippingFee=$('#shipping_'+shipping).html();
            if(!paymentFee){
                paymentFee=0;
            }
            if(!shippingFee){
                shippingFee=0;
            }
            total=parseFloat(paymentFee*total*0.01)+total;
            total=(parseFloat(shippingFee)+total).toFixed(1);
            $('#total').html(total);
            $('.total').html(total);
        }
    </script>
</div>
<?php echo W('Footer');?>